package com.wzh.provicer;

import com.wzh.core.api.entity.RpcRequest;
import com.wzh.core.api.entity.RpcResponse;
import com.wzh.core.config.ProviderConfig;
import com.wzh.core.provider.ProviderBootstrap;
import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import;
import org.springframework.web.bind.annotation.*;

@RestController
@SpringBootApplication
@Import(ProviderConfig.class)
public class RpcDemoProvicerApplication {

    private static final Logger log = LoggerFactory.getLogger(RpcDemoProvicerApplication.class);
    @Resource
    private ProviderBootstrap providerBootstrap;

    public static void main(String[] args) {
        SpringApplication.run(RpcDemoProvicerApplication.class, args);


    }

    /**
     * Http + JSON 的方式 提供通信
     * 请求入参 RpcRequest
     * 响应出参 RpcResponse
     */
    @RequestMapping(value = "/", method = RequestMethod.POST)
    public RpcResponse<Object> getRpcResponse(@RequestBody RpcRequest rpcRequest) {
        log.info("请求参数：{}", rpcRequest);
        return providerBootstrap.invokeMethod(rpcRequest);
    }










}


